/**
 * @file   1129.cpp
 * @author Shuang Hu <hsmath@ubuntu>
 * @date   Wed Jul  7 06:43:13 2021
 * 
 * @brief  PAT 1129
 * 
 * 
 */
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main(){
    int num;
    int K;
    cin>>num>>K;
    vector<int> recom;
    map<int,int> appeartimes;
    vector<int> rank;
    for(int i=0;i<num;i++){
	int d;
	cin>>d;
	recom.push_back(d);
    }
    appeartimes[recom[0]]=1;
    rank.push_back(recom[0]);
    int flag=1;
    for(int i=1;i<num;i++){
	cout<<recom[i]<<":";
	for(int j=flag;j>0;j--){
	    if(appeartimes[rank[j]]<appeartimes[rank[j-1]]){
		break;
	    }else if(appeartimes[rank[j]]==appeartimes[rank[j-1]]){
		if(rank[j]>rank[j-1]){
		    break;
		}
	        else{
		int tmp=rank[j];
		rank[j]=rank[j-1];
		rank[j-1]=tmp;
		}
	    }else{
		int tmp=rank[j];
		rank[j]=rank[j-1];
		rank[j-1]=tmp;
	    }
	}
	int d=rank.size();
	for(int i=0;i<d&&i<K;i++){
	    cout<<" "<<rank[i];
	}
	cout<<endl;
	flag=rank.size()-1;
	if(appeartimes.count(recom[i])==0){//haven't registered
	    appeartimes[recom[i]]=1;
	    rank.push_back(recom[i]);
	    flag++;
	}else{
	    appeartimes[recom[i]]++;
	    for(int j=0;j<rank.size();j++){
		if(rank[j]==recom[i]){
		    flag=j;
		    break;
		}
	    }
	}
    }
}
